#!/bin/bash
f=/home/`whoami`/tf
g=/home/`whoami`/tf/tlog.txt
b=0
if [ -d $f ]
then
   echo "the backup file--tf exists"
else
   mkdir $f
   touch $g
   echo "created backup file--tf file"
fi
a=1
while [ $a = 1 ]
do
echo "input a directory"
read name
if [ -f $name -o -d $name ]
then
   echo "the source file exists"
   s=`cat $g|grep $name`
   if [ -n "$s" ]
   then
 echo "the source file has been backed up"
   b=1
   fi
else
   echo "the source file does not exit"
   b=1
fi
if [ $b = 0 ]
then
tar -czvf $name.tar.gz $name>/dev/null 2>&1
t=`date +%-d-%-m-%Y_%T`
mv $name.tar.gz $name-$t.tar.gz
mv $name-$t.tar.gz $f
echo "name:$name-$t.tar.gz">>$g
echo "source file:$name">>$g
echo "tarfilem file:$f">>$g
echo "create tiem:$t">>$g
echo "******************************">>$g
echo "complete operation"
fi
echo "continue?(y/n)"
read choose
if [ $choose = y ]
then
a=1
else
exit 0
fi
done
